<!--培训系统模板-->
<template>
<div class="content"> 
    <Back v-bind:isDefault="true"></Back>
		<Battery></Battery>
		<Title v-bind:hasHelp="false" v-bind:title="title"></Title>
		<div class="spare-a">
			<div class="questions-ar">
				<div class="spare-ara">
					<!-- <div class="recautions-a"><span>{{fileList}}</span></div> -->
					<div class="documentation paper">
						<ul>
							  <li v-for="data in datas" :key="data.id" >
                  <div class="paper-a"  @click="clickPms(data.isDm,'/ietm/data/'+data.id,data.id,data.title,data.orderCode)">{{data.title}}</div>
                </li>
						</ul>
					</div>
				</div>
			</div>
		</div>
</div>
</template>

<script>
import Battery from '@/components/Battery'
import Title from '@/components/Title'
import Back from '@/components/Back'
export default {
  name: 'Pms',
  components:{
    Battery,
    Title,
    Back
  },
  data () {
    return {
     title:'',
     pid:'',//父页面获取到的值
     isInit:true,
     datas:[],
     applic:''
    // fileList:'文件列表',
     //folderList:'文件夹列表'
    }
  },methods:{
      clickPms:function(isDm,url,id,title,orderCode){
        if(isDm){
        this.$router.push({name:'Content',params: { id:id,title:title,orderCode:orderCode }})
        }else{
          this.clickFolder(url)
        }
      },
     clickFolder:function(url){
        this.axios.get(url,{params:{type:"pds",applic:this.applic}}).then(res=>{
             this.datas=res.data.pds;
        });
      },getData:function(){
      //渲染左侧数据
      this.axios.get("/ietm/data/"+this.pid,{params:{type:"pds",applic:this.applic}}).then(res=>{
        this.datas=res.data.pds;
      });
      }
  },created(){
    this.isInit=true;
  },beforeRouteLeave(to,from,next){//该方法有问题
    if(to.name==='Ietm')this.isInit=true; 
		next();
 },activated() {//缓存被触发时
 this.applic= window.localStorage.getItem("applic");
 if (this.$route.params.id){//如果从上一个页面跳转过来，获取路由数据，同时存储到本地,防止刷新数据丢失
      this.pid = this.$route.params.id;
      this.title = this.$route.params.title;
      window.localStorage.setItem("Pms_Pid",this.$route.params.id);
		  window.localStorage.setItem("Pms_Title",this.$route.params.title);
    } else{
      this.pid = window.localStorage.getItem("Pms_Pid");
      this.title = window.localStorage.getItem("Pms_Title");
    }
	if(this.isInit){
		this.getData();
		this.isInit=false;
	}
} 
 
}
</script>

<style scoped>
@import url('../../assets/css/content.css');
@import url('../../assets/css/animation.css');
</style>
